<template>
	<view class="container">
		<lee-linkage v-if="show == 1" :list="dataList" @onGoodItem="onGoodItem"></lee-linkage>
		<lee-linkage v-if="show == 2" :list="dataList" @onGoodItem="onGoodItem">
			<template v-slot:custom="{row}">
				<view>自定义插槽内容</view>
				<view class="" v-for="(item,index) in row.foods">
					{{item.name}}
				</view>
			</template>
		</lee-linkage>
	</view>
</template>

<script>
	import leeLinkage from '../../components/StarLee-linkage/linkage.vue'
	export default {
		components: {
			leeLinkage
		},
		data() {
			return {
				show: 1, //1默认，2自定义插槽
				dataList: [{
						"name": "蔬菜",
						"foods": [{
								"cat": 1,
								"name": "平武油麦菜",
								"icon": "http://www.quanyuntong.cn/news2/goods1.jpg",
								"key": "平武油麦菜"
							},
							{
								"cat": 2,
								"name": "平武野菜",
								"icon": "http://www.quanyuntong.cn/news2/goods2.jpg",
								"key": "平武野菜"
							},
							{
								"cat": 3,
								"name": "折耳根",
								"icon": "http://www.quanyuntong.cn/news2/goods3.jpg",
								"key": "折耳根"
							}
						]
					},
					{
						"name": "水果",
						"foods": [{
								"cat": 4,
								"name": "猕猴桃",
								"icon": "http://www.quanyuntong.cn/news2/goods4.jpg",
								"key": "猕猴桃"
							},
							{
								"cat": 5,
								"name": "耙耙柑",
								"icon": "http://www.quanyuntong.cn/news2/goods5.jpg",
								"key": "耙耙柑"
							},
							{
								"cat": 6,
								"name": "柚子",
								"icon": "http://www.quanyuntong.cn/news2/goods6.jpg",
								"key": "柚子"
							}
						]
					},
					{
						"name": "肉类",
						"foods": [{
								"cat": 8,
								"name": "猪肉",
								"icon": "http://www.quanyuntong.cn/news2/goods7.jpg",
								"key": "猪肉"
							}, {
								"cat": 9,
								"name": "牛肉",
								"icon": "http://www.quanyuntong.cn/news2/goods8.jpg",
								"key": "牛肉"
							},
							{
								"cat": 10,
								"name": "羊肉",
								"icon": "http://www.quanyuntong.cn/news2/goods9.jpg",
								"key": "羊肉"
							}
						]
					},

					{
						"name": "山野干货",
						"foods": [{
								"cat": 16,
								"name": "木耳",
								"icon": "http://www.quanyuntong.cn/news2/goods10.jpg",
								"key": "木耳"
							},
							{
								"cat": 17,
								"name": "羊肚菌",
								"icon": "http://www.quanyuntong.cn/news2/goods11.jpg",
								"key": "羊肚菌"
							}
						]
					},

					{
						"name": "其他",
						"foods": [{
								"cat": 434,
								"name": "平武蜂蜜",
								"icon": "http://www.quanyuntong.cn/news2/goods12.jpg",
								"key": "平武蜂蜜"
							},
							{
								"cat": 435,
								"name": "平武核桃",
								"icon": "http://www.quanyuntong.cn/news2/goods13.jpg",
								"key": "平武核桃"
							}
						]
					}
				]
			}
		},
		methods: {
			onGoodItem(item) {
				console.log(item);
				uni.showToast({
					title: `点击了 ${item.name}`,
					icon: 'none'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		background-color: #F6F6F6;
		min-height: 100vh;
	}
</style>